#include "lan2calbtn.h"
#include "lan2calhead.h"

#include <QLabel>
#include <QPushButton>
#include <qdatetime.h>
#include <QDate>
#include <QDebug>
LAN2STA
Lan2CalHead::Lan2CalHead(QWidget *parent, int width, int height) : QWidget(parent)
{
   this->setAttribute(Qt::WA_StyledBackground,true);
    this->setStyleSheet("background:#fdfdfd");


    hbox_head=new QHBoxLayout();
    this->setLayout(hbox_head);
    Lan2CalBtn* pb_leftyy=new Lan2CalBtn(this,QStringLiteral("<<"));
    Lan2CalBtn* pb_leftMM=new Lan2CalBtn(this,QStringLiteral("<"));
    Lan2CalBtn* pb_rightyy=new Lan2CalBtn(this,QStringLiteral(">>"));
    Lan2CalBtn* pb_rightMM=new Lan2CalBtn(this,QStringLiteral(">"));
    connect(pb_leftMM,SIGNAL(clicked(bool)),this,SLOT(slot_leftMM()));
    connect(pb_leftyy,SIGNAL(clicked(bool)),this,SLOT(slot_leftyyyy()));
    connect(pb_rightMM,SIGNAL(clicked(bool)),this,SLOT(slot_rightMM()));
    connect(pb_rightyy,SIGNAL(clicked(bool)),this,SLOT(slot_rightyyyy()));


   lal_yyyyMM=new QLabel(this);
   QFont f;
   f.setPointSize(12);
   lal_yyyyMM->setFont(f);
   lal_yyyyMM->setFixedWidth(100);

//   qDebug()<<QDate::currentDate().year()<<QDate::currentDate().month();
   method_setyyyyMM(QDate::currentDate().year(),QDate::currentDate().month());

    hbox_head->addWidget(pb_leftyy);
    hbox_head->addWidget(pb_leftMM);
    hbox_head->addStretch();
    hbox_head->addWidget(lal_yyyyMM);
    hbox_head->addStretch();

    hbox_head->addWidget(pb_rightMM);
    hbox_head->addWidget(pb_rightyy);
//    this->setFixedHeight(50);
    this->setFixedSize(width,height);
}

void Lan2CalHead::method_setyyyyMM(int yyyy, int MM)
{
    lal_yyyyMM->setText(QString("%1年%2月").arg(yyyy).arg(MM));

}

void Lan2CalHead::slot_leftMM()
{
    emit sign_leftMM();
}

void Lan2CalHead::slot_leftyyyy()
{
    emit sign_leftyyyy();
}

void Lan2CalHead::slot_rightMM()
{
    emit sign_rightMM();
}

void Lan2CalHead::slot_rightyyyy()
{
    emit sign_rightyyyy();
}

LAN2END
